package net.pulseproject.router.systemtest;

import net.pulseproject.commons.midi.entity.MidiSocket;
import net.pulseproject.router.config.parser.LineConfig;
import net.pulseproject.router.systemtest.LineConfigBuilder.MidiReceiverConfigBuilder;
import net.pulseproject.router.systemtest.LineConfigBuilder.MidiTransmitterConfigBuilder;

public class LineConfigSimpleCreator {

	public final LineConfig forReceiverWith(final String id, final MidiSocket socket) {
		return new MidiReceiverConfigBuilder().
			id(id).
			port(socket.getPort()).
			channel(socket.getChannel().intValue() + 1 /* 0-based to 1-based indexed*/).
			controller(socket.getController().intValue()).
			build();
	}

	public final LineConfig forTransmitterWith(final String id, final MidiSocket socket,
			final String... outgoingIds) {
		final MidiTransmitterConfigBuilder builder = new MidiTransmitterConfigBuilder().
			id(id).
			port(socket.getPort()).
			channel(socket.getChannel().intValue() + 1 /* 0-based to 1-based indexed*/).
			controller(socket.getController().intValue());
		for (final String outgoingId : outgoingIds) {
			builder.addOut(outgoingId);
		}
		return builder.build();
	}
	
}
